package com.ball.snake;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;

import java.util.Random;

/**
 * Created by Administrator on 2018/9/17 0017.
 */

public class Food {
    private int x;
    private int y;
    private Random random;
    public  int color=Color.CYAN;
    public static final int WIDTH = 10;

   public Food(){
       random=new Random();
   }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public void draw(Canvas canvas,Paint paint){
       paint.setColor(color);
       paint.setAlpha(150);
       canvas.drawRect(x,y,x+WIDTH,y+WIDTH,paint);
    }

    public void reset(){
        x=random.nextInt(75)*WIDTH;
        y=random.nextInt(128)*WIDTH;
    }

    public  int getColor() {
        return color;
    }

    public  void setColor(int color) {
        this.color = color;
    }
}
